package cn.wolfcode.trip.admin.controller;

import cn.wolfcode.trip.base.query.IntegralQueryObject;
import cn.wolfcode.trip.base.service.IIntegralService;
import cn.wolfcode.trip.base.service.IIntegralTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * Copyright: Copyright (c) 2019 Super520
 * 描述：积分明细控制器
 *
 * @package: cn.wolfcode.trip.admin.controller
 * @author: Patch
 * @date: 2019/5/30 10:02
 * 总结:
 */
@Controller
@RequestMapping("integral")
public class IntegralController {
    @Autowired
    private IIntegralService integralService;
    @Autowired
    private IIntegralTypeService typeService;

    @RequestMapping("list")
    public String list(Model model, @ModelAttribute("qo") IntegralQueryObject qo) {
        // 设置根据创时间排序
        qo.setOrderBy("i.inputTime desc");
        model.addAttribute("pageInfo", integralService.query(qo));
        // 查询所有的类型
        model.addAttribute("types", typeService.listAll());
        return "integral/list";
    }
}
